<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>领券</title>
    <link href="css/mui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/aui.css"/>
    <link rel="stylesheet" href="css/shop.css">
    <link rel="stylesheet" href="css/alert.css">
    <script src="js/jquery-1.8.2.min.js"></script>
    <script src="js/mui.min.js"></script>
    <script>

        var autoload=function () {
            var data={};
            data.user_id=user_id;
            data.userpwd=userpwd;
            data.id=getQueryString("id")
            if(user_id==""){
                return;
            }
            $.ajax({
                type: "POST",
                //url: "http://test/jsonp.php",
                data: data,
                url: "http://xjh.taoleyizhan.com/wap/index.php?ctl=shopdetail&act=index",
                dataType: "json",
                success: function (json) {
                    console.log(json)
                    page_data = json
                    $('#quanname').html(page_data.ticket_info.name);
                    $('#getquan').attr('data-id',page_data.ticket_info.id)
                    $('#pay-money').html(page_data.ticket_info.current_price);
                    $('#jifen').html(page_data.ticket_info.current_price);
                    $('#buy').attr('data-id',page_data.ticket_info.id)
                    //InitChat();

                },
                error: function (json) {
                    console.log(json);
                }
            })
        }
    </script>
    <script src="js/init.js"></script>
</head>
<body>
    <header class="mui-bar mui-bar-nav">
        <a href="javascript:history.go(-1)" class="mui-icon-undo mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title" >领券</h1>
    </header>

    <div class="mui-content aui-pad-15 f14 change">
        <div class="aui-pad-t-10 aui-pad-b-10 flex">
            <img class="f1 aui-col-3 aui-mar-r-10" src="image/banner.png" alt="">
            <div class="f3">
                <div id="quanname">Apple ipad 9.7英寸（64G Wi-Fi版）灰色</div>
                <div>￥ <span class="aui-color-red">100</span> <span class="f10">商品原价：3888元</span></div>
            </div>
        </div>
        <div class="list_con aui-pad-10 aui-mar-b-15">购买数量
            <div class="fr f14 mui-text-right">
                <span class="duo_jian f20">-</span>
                <input id="buy_num" style="width:30%;height:20px;padding:5px;font:12px/14px '';margin:0 10px;text-align:center;" type="text" value="1">
                <span class="duo_jia">+</span>
            </div>
        </div>
        <div class="list_con aui-pad-10 aui-mar-b-15">
            赠送积分
            <div class="fr"><img src="images/zuan.png" alt="" width="14"><span id="jifen">788</span></div>
        </div>
        <div class="aui-color-gray mui-text-center aui-pad-10 f12">
            <input type="radio">
            <label class="aui-pad-l-5" for="">我已同意并阅读《券游商城服务协议》</label>
        </div>
    </div>
    <div class="fix aui-col-10 aui-pad-10 aui-background-yellow mui-text-center f14 change" id="buy" data-id="" style="left:0;bottom:0;">支付：<b id="pay-money"></b></div>
    <iframe id="paymentframe" src="" style="width: 100%;height: 900px;outline:none;border: none; display: none"></iframe>
</body>
<script src="js/alert.js"></script>
<script>
    var lock=0
    $(".duo_jia").click(function () {
        var nums=$("#buy_num").val();
        var ticket_price=page_data.ticket_info.current_price;
        var newnums=nums*1+1;
        var price=newnums*ticket_price;
        var jifen=newnums*ticket_price;
        $("#buy_num").val(newnums);
        $("#pay-money").html(price)
        $("#jifen").html(price)
    })
    $(".duo_jian").click(function () {
        var nums=$("#buy_num").val();
        if(nums==1){
            return;
        }
        var ticket_price=page_data.ticket_info.current_price;
        var newnums=nums*1-1;
        var price=newnums*ticket_price;
        var jifen=newnums*ticket_price;
        $("#buy_num").val(newnums);
        $("#pay-money").html(price)
        $("#jifen").html(price)
    })
    $('#buy').click(function () {
        if(lock==0){
            lock=1;
            var ticket_id=$(this).attr('data-id')
            var nums=$('#buy_num').val();
            var payment_id=5;
            var data={}
            data.user_id=user_id;
            data.userpwd=userpwd;
            data.product_id=ticket_id;
            data.payment_id=payment_id
            data.nums=nums;
            if(payment_id==7){

            }else{
                $.ajax({
                    type: "POST",
                    //url: "http://test/jsonp.php",
                    data: data,
                    url: "http://xjh.taoleyizhan.com/wap/index.php?ctl=uc_charge&act=order_done",
                    dataType: "json",
                    success: function (json) {
                        console.log(json)
                        if(json.status ==1 ){
                            //window.location.href=data.jump;
                            $("#paymentframe").attr("src",json.jump);
                            $(".change").hide()
                            $("#paymentframe").show()
                        }else{
                            alert(data.info);
                        }

                        lock=0;
                    },
                    error: function (json) {
                        console.log(json);
                        lock=0;
                    }
                })
            }
            lock=0;
        }

    })
</script>
</html>